﻿using System.Linq;
using System.Windows.Forms;
using IGM.DataProvider.Entites;
using IGM.Presentation.IgmServiceReference;

namespace IGM.Presentation.Main
{
    public partial class Login : UserControl
    {
        private readonly DomainServiceClient _domainServiceClient;

        public Login()
        {
            InitializeComponent();
            _domainServiceClient = new DomainServiceClient();            
        }

        private void LoginLoad(object sender, System.EventArgs e)
        {
            LoadMajors();
            LoadKindInterns();
            Dock = DockStyle.Top;
        } 

        private void LoadMajors()
        {
            cboMajors.DataSource = _domainServiceClient.GetMajors().Cast<Major>().ToList();
            cboMajors.DisplayMember = "Name";
            cboMajors.ValueMember = "Id";
        }
        private void LoadKindInterns()
        {
            cboKindInterns.DataSource = _domainServiceClient.GetKindInterns().Cast<KindIntern>().ToList();
            cboKindInterns.DisplayMember = "Name";
            cboKindInterns.ValueMember = "Id";
        }
        private void BtnCancelClick(object sender, System.EventArgs e)
        {
            txtUsername.Text = txtPassword.Text = string.Empty;
            cboMajors.DataSource = cboKindInterns.DataSource = null;
        }          
    }
}
